<style scoped>
.quote{
    padding-top: 20px;
    position: relative;
    padding-bottom: 50px;
}
.quote-box{
    background-color: #f8f8f8;
    width: 86%;
    margin: 0 auto;
    padding: 15px;
    margin-bottom: 15px;
}
.col-item{
    margin-bottom: 15px;
}
.quote-result{
    border: 1px solid #ddd;
    width: 86%;
    margin: 0 auto;
    padding: 15px;
    line-height: 100px;
}
.quote-result-txt{
    text-align: center;
}
.quote-price{
    color: red;
}
.quote-price b{
    font-size: 20px;
    color: red;

}
</style>
<style>

</style>

<template>
    <div class="quote">        
        <div class="quote-box">
            <Row>
                <Col span="12" class="col-item">
                    车牌号码：{{info.LicenseNo}}
                </Col>
                <Col span="12" class="col-item">
                    车主姓名：{{info.UserInfo.LicenseOwner}}
                </Col>
                <Col span="24" class="col-item">
                    品牌型号：{{info.UserInfo.ModleName}}
                </Col>
                <Col span="12" class="col-item">
                    交强险到期时间：{{info.UserInfo.ForceExpireDate}}
                </Col>
                <Col span="12" class="col-item">
                    商业险到期时间：{{info.UserInfo.BusinessExpireDate}}
                </Col>
            </Row>
        </div>
        <div>
            <div class="quote-result" v-for="(item,index) in coms" :key="item">
                <Row>
                    <Col span="6" class="quote-result-txt">
                        {{company[item].name}}
                    </Col>
                    <Col span="6" class="quote-result-txt">
                        <div class="quote-price" v-if="hasprice">
                            <b>报价中……</b>                          
                        </div>
                        <div class="quote-price" v-else>
                             <b>{{price[item].Item.BizTotal + price[item].Item.ForceTotal + price[item].Item.TaxTotal}}</b>元
                        </div>
                    </Col>
                    <Col span="6" class="quote-result-txt">
                        <div v-if="hasprice">
                            核价中……
                        </div>
                        <div v-else>
                            {{price[item].submit.Item.SubmitResult}}
                        </div>                         
                    </Col>
                    <Col span="6" class="quote-result-txt">
                        <a>查看详情</a>
                    </Col>
                </Row>
            </div>             
        </div>                                                                
    </div>
</template>

<script>
import productTitle from '../../components/productTitle'
import { getQuote , getBaseQuoteInfo } from '../../api/car'
export default {
    data() {
        return {           
            coms:[

            ],
            info:{
                LicenseNo:'',
                UserInfo:{
                    LicenseOwner:'',
                    ModleName:'',
                    ForceExpireDate:'',
                    BusinessExpireDate:'',
                }

            },
            hasprice:true,
            price:{
                1:{
                    Item:{
                        BizTotal:0,
                        ForceTotal:0,
                        TaxTotal:0,                       
                    },
                    submit:{
                        Item:{
                            SubmitResult:'未意向核保'
                        }
                    }                   
                },
                2:{
                    Item:{
                        BizTotal:0,
                        ForceTotal:0,
                        TaxTotal:0
                    },
                    submit:{
                        Item:{
                            SubmitResult:'未意向核保'
                        }
                    }
                },
                4:{
                    Item:{
                        BizTotal:0,
                        ForceTotal:0,
                        TaxTotal:0
                    },
                    submit:{
                        Item:{
                            SubmitResult:'未意向核保'
                        }
                    }
                },
                8:{
                    Item:{
                        BizTotal:0,
                        ForceTotal:0,
                        TaxTotal:0
                    },
                    submit:{
                        Item:{
                            SubmitResult:'未意向核保'
                        }
                    }
                },
                16:{
                    Item:{
                        BizTotal:0,
                        ForceTotal:0,
                        TaxTotal:0
                    },
                    submit:{
                        Item:{
                            SubmitResult:'未意向核保'
                        }
                    }
                },
                32:{
                    Item:{
                        BizTotal:0,
                        ForceTotal:0,
                        TaxTotal:0
                    },
                    submit:{
                        Item:{
                            SubmitResult:'未意向核保'
                        }
                    }
                },
                2048:{
                    Item:{
                        BizTotal:0,
                        ForceTotal:0,
                        TaxTotal:0
                    },
                    submit:{
                        Item:{
                            SubmitResult:'未意向核保'
                        }
                    }
                }
            },
            company:{
                1:{
                    id:"tpy",
                    name:"太平洋",                    
                },
                2:{
                    id:"pa",
                    name:"平安", 
                },
                4:{
                    id:"rb",
                    name:"人保", 
                },
                8:{
                    id:"gsc",
                    name:"国寿财", 
                },
                16:{
                    id:"zhlh",
                    name:"中华联合", 
                },
                32:{
                    id:"tpy",
                    name:"大地", 
                },
                2048:{
                    id:"astp",
                    name:"安盛天平", 
                }
            },
        }
            
    },
    components: {
        
    },
    computed:{
        
        
    },
    created() {
        this.getbaseinfo()
        
    },
    methods: {
        getquote() {
            var _params = {
                id:this.$route.params.id
            }
            new Promise((resolve, reject) => {
                getQuote(_params).then(response => {
                    console.log(response.data)
                    this.hasprice = false
                    if (response.data.err == 0) {
                       this.price = response.data.data.price
                    } else {
                        
                    }
                    resolve();
                }).catch(error => {
                    reject(error);
                });
            });
        },
        getbaseinfo() {
            var _params = {
                id:this.$route.params.id
            }
            new Promise((resolve, reject) => {
                getBaseQuoteInfo(_params).then(response => {
                    console.log(response.data)
                    if (response.data.err == 0) {
                       this.coms = response.data.data.coms
                       this.info = response.data.data.info
                       for(var i=0;i<this.coms.length;i++){
                           var num = this.coms[i]                                                   
                       }
                       this.getquote()
                    } else {
                        
                    }
                    resolve();
                }).catch(error => {
                    reject(error);
                });
            });
        }
        
    }
};
</script>
